import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)

import Index from '@/views/Index/Index.vue'

const routes = [
  {
    path: '/',
    redirect: '/index'
  },
  {
    path: '/index',
    name: 'index',
    component: Index
  },
  {
    path: '/signUp',
    name: 'signUp',
    component: () => import('@/views/SignUp/SignUp.vue')
  },
  {
    path: '/signIn',
    name: 'signIn',
    component: () => import('@/views/SignIn/SignIn.vue')
  },
  {
    path: '/attachmentManagement',
    name: 'attachmentManagement',
    component: () => import('@/views/AttachmentManagement/AttachmentManagement.vue')
  },
  {
    path: '/userManagement',
    name: 'userManagement',
    component: () => import('@/views/UserManagement/UserManagement.vue')
  },
  {
    path: '/cateManagement',
    name: 'cateManagement',
    component: () => import('@/views/CategoriesManagement/CategoriesManagement.vue')
  }
]

const router = new VueRouter({
  routes,
  scrollBehavior(to, from, savedPosition) {
    if (savedPosition) {
      return savedPosition
    } else {
      return { x: 0, y: 0 }
    }
  }
})

export default router
